package ch.fhnw.qualiscan.application.elements;

import ch.fhnw.qualiscan.AppObject;
import ch.fhnw.qualiscan.core.helpers.TextHelper;
import ch.fhnw.qualiscan.core.libraries.UrlLib;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CustomLayout;

import eu.livotov.tpt.TPTApplication;
import eu.livotov.tpt.i18n.TM;

@SuppressWarnings("serial")
public class Reminder extends CustomLayout {
	AppObject dataObject;
	public Reminder(String date, String task, final String url) {
		setTemplateName("custom/ReminderBox");
		dataObject = (AppObject) TPTApplication.getCurrentApplication().getMainWindow().getData();
		TextHelper text = new TextHelper();
		
		addComponent(text.span(date), "date");
		addComponent(text.span(task), "task");
		
		Button actionButton = new Button(TM.get("reminder.button"));
		actionButton.addListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {
				UrlLib urlLib = dataObject.getUrlLib();
				urlLib.setFragment(url, true);
			}
		});
		
		addComponent(actionButton, "action");
	}
	
}
